<?php

include_once("../../php/postgre.php");
$code = $_GET['cde'];
if ($code == 'pro') {
    $idpro = $_GET[idpro];
    $program = get_datas("select * from mus_kegiatan WHERE id_program=$idpro");

    foreach ($program as $program) {
        $idkeg = $program['id_keg'];
        $namakeg = $program['nama_kegiatan'];
        echo "<div class='item_keg'><input type='radio' name='kegi' id='kegi' onclick='onclickKegiatan(this.value,$idpro)' value='$idkeg'>&nbsp;$namakeg</input></div>";
    }
}elseif ($code == 'text'){
    $idPro = $_GET['pro'];
    $keg = $_GET['kgt'];
    $nmPro = get_data("SELECT nama_program FROM mus_program where id_program = $idPro");
    $nmKeg = get_data("SELECT nama_kegiatan FROM mus_kegiatan where id_keg = $keg");
    echo $nmPro['nama_program']." | ".$nmKeg['nama_kegiatan'];
}elseif ($code == 'lap'){
	$thn = $_GET['thn'];
	$lap_udesa = get_datas ("select distinct u.id_usulankec, u.id_kegiatan, s.nama_skpd, u.indikator_hasil, u.indikator_program, u.indikator_keluaran, u.target_hasil, u.tahun, u.kegiatan from mus_usulankecamatan u, mus_kegiatan k, mus_skpd s where s.id_skpd=u.id_skpd and (u.id_kegiatan=k.id_keg or u.id_kegiatan=0) and u.tahun= $thn order by u.id_usulankec");
	
	if(count($lap_udesa) > 0){
 		foreach($lap_udesa as $udesa){
					if ($udesa['id_kegiatan'] == 0 ){
						$nama_kegiatan = $udesa['kegiatan'];
					}else{
						$desa = get_data ("select nama_kegiatan from mus_kegiatan where id_keg=".$udesa['id_kegiatan']);
						$nama_kegiatan = $desa['nama_kegiatan'];
					}
                ?>
                <tr>
                    <td style="text-align:center"><?php echo $udesa['id_usulankec']?></td>
                    <td><a href="#showDetail" data-toggle="modal" id="kegiatan" name="kegiatan" onclick="detail(<?php echo $udesa['id_usulankec']?>)"><?php echo $nama_kegiatan ?></a></td>
                    <td><?php echo $udesa['indikator_program']?></td>
                    <td><?php echo $udesa['indikator_keluaran']?></td>
                    <td style="text-align:center"><?php echo $udesa['nama_skpd']?></td>
                    <td style="text-align:center"><?php echo $udesa['tahun']?></td>
                    <td style="text-align:center;">
                        <a href="#collapseTwo" data-toggle="collapse" data-parent="#accordion2" class="btn btn-info btn-small bt-edit-udesa" name="<?php echo $udesa['id_usulankec']; ?>"><i class="icon-edit icon-white"></i>Ubah</a>
                        <a class="btn btn-danger btn-small bt-delete-udesa" name="<?php echo $udesa['id_usulankec']; ?>"><i class="icon-trash icon-white"></i>Hapus</a>
                        </td>
                </tr>
                <?php
           }
	}else{
        echo "<tr><td colspan='7'><div class='alert center'>Tidak ada data</div></td></tr>";
	}
}
?>